import request from "@/utils/request";

/**
 * 获取员工列表
 * @param {Object} query 查询参数
 * @returns Promise
 */
export const getEmployeeListAPI = (query) => {
  return request({
    method: "get",
    url: "/sys/user",
    params: query,
  });
};

/**
 * 删除员工
 * @param {String} id 员工id
 * @returns Promise
 */
export const delEmloyeeAPI = (id) => {
  return request({
    method: "delete",
    url: `/sys/user/${id}`,
  });
};

/**
 * 单个增加员工
 * @param {Object} employeesForm
 * @returns Promise
 */
export const addEmployeeAPI = (employeesForm) => {
  return request({
    method: "post",
    url: "/sys/user",
    data: employeesForm,
  });
};

export const addEmployeeBatchAPI = (employeeList) => {
  return request({
    method: "post",
    url: "/sys/user/batch",
    data: employeeList,
  });
};

/**
 *获取员工讯息
 * @param {String} employeeId
 * @returns
 */
export const getEmployeeInfoAPI = (employeeId) => {
  return request({
    method: "get",
    url: `/sys/user/${employeeId}`,
  });
};

export const updateEmployeeAPI = (employeesForm) => {
  return request({
    method: "put",
    url: `/sys/user/${employeesForm.id}`,
    data: employeesForm,
  });
};
/**
 *
 * @param {*} id
 * @param {*} roleIds
 * @returns
 */
export const assignRoleAPI = (id, roleIds) => {
  return request({
    method: "put",
    url: "/sys/user/assignRoles",
    data: {
      id,
      roleIds,
    },
  });
};
